<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="list"></div>
    <script src="jslib/mustache.js"></script>
    <script>
        // 循环数组
        var templateStr = `
            <ul>
                {{#arr}}
                <li>
                    <p>姓名：{{name}}</p>
                    <ol>
                        {{#hobbies}}
                            <li>{{.}}</li>
                        {{/hobbies}}
                    </ol>
                </li>
                {{/arr}}
            </ul>
        `;

        var data = {
            arr: [{
                    name: '小明',
                    age: 12,
                    sex: 'f',
                    hobbies: ["第一个", "第二个"]
                },
                {
                    name: '小红',
                    age: 11,
                    sex: 'm',
                    hobbies: ["第三个", "第四个"]
                },
                {
                    name: '小强',
                    age: 13,
                    sex: 'f',
                    hobbies: ["第五个", "第六个"]
                },
            ]
        }

        var domStr = Mustache.render(templateStr, data);
        console.log(domStr);

        let div = document.querySelector("div");
        div.innerHTML = domStr;
    </script>
</body>

</html>